package com.hex.ds.hdtp.core.inf.data.table.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hex.ds.hdtp.core.inf.data.table.po.TableTransferListPo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.sql.Clob;
import java.util.List;

/**
 * @Package com.hex.ds.hdtp.core.inf.data.table.mapper
 * @ClassName ITableTransferListMapper
 * @Description 表迁移-数据映射接口
 * @Author Wang zhihao
 * @Date 2023/8/9 11:14
 * @Version v1.0
 **/
@Repository
public interface ITableTransferListMapper extends BaseMapper<TableTransferListPo> {

    /**
     * @Method queryListByPage
     * @Param
     * @param toMyBatisPlusPage
     * @param tableTransferListPo
     * @Return com.baomidou.mybatisplus.core.metadata.IPage<com.hex.ds.hdtp.core.inf.data.table.po.TableTransferListPo>
     * @Description 分页查询
     * @Author Wang zhihao
     * @Date 2023/8/9 11:15
     * @Version V1.0
     */
    IPage<TableTransferListPo> queryListByPage(IPage<TableTransferListPo> toMyBatisPlusPage,
                                               @Param("po") TableTransferListPo tableTransferListPo);

    /**
     * 根据任务主键分页查询
     *
     * @param toMyBatisPlusPage
     * @param tableTransferListPo
     * @return
     */
    IPage<TableTransferListPo> queryPageListByTaskId(IPage<TableTransferListPo> toMyBatisPlusPage,
                                               @Param("po") TableTransferListPo tableTransferListPo);

    /**
     * @Method queryLatestSuccess
     * @Param
     * @param toMyBatisPlusPage
     * @param tableTransferListPo
     * @Return com.baomidou.mybatisplus.core.metadata.IPage<com.hex.ds.hdtp.core.inf.data.table.po.TableTransferListPo>
     * @Description 表迁移清单-分页查询每个建表最新成功的
     * @Author Wang zhihao
     * @Date 2023/8/28 11:14
     * @Version V1.0
     */
    IPage<TableTransferListPo> queryLatestSuccess(IPage<TableTransferListPo> toMyBatisPlusPage,
                                                  @Param("po") TableTransferListPo tableTransferListPo);

    /**
     * @Method queryList
     * @Param
     * @param tableTransferListPo
     * @Return java.util.List<com.hex.ds.hdtp.core.inf.data.table.po.TableTransferListPo>
     * @Description 不分页查询
     * @Author Wang zhihao
     * @Date 2023/8/10 14:32
     * @Version V1.0
     */
    List<TableTransferListPo> queryList(@Param("po") TableTransferListPo tableTransferListPo);


    /**
     * @Method queryLatestTransferTable
     * @Param
     * @Param sourceDbName
     * @Param sourceTableName
     * @Return java.util.List<com.hex.ds.hdtp.core.inf.data.table.po.TableTransferListPo>
     * @Description 根据源库名表名查询最新的迁移表信息
     * @Author gj.xu
     * @Date 2023/8/29 11:40
     * @Version V2.0
     */
    TableTransferListPo queryLatestTransferTable(String sourceDbName, String sourceTableName);

    /**
     * @Method queryLatestTransferTableByTarget
     * @Param targetDbName
     * @Param targetTableName
     * @Return com.hex.ds.hdtp.core.inf.data.table.po.TableTransferListPo
     * @Description 根据目标库名表名查询最新的迁移表信息
     * @Author Yin.Yang
     * @Date 2023/9/27 16:42
     * @Version V1.0
     */
    TableTransferListPo queryLatestTransferTableByTarget(String targetDbName, String targetTableName, String targetPkId);

    /**
     * @Method deleteByTaskPkId
     * @Param
     * @param taskPkId
     * @Return void
     * @Description 根据主键删除
     * @Author Wang zhihao
     * @Date 2023/8/10 18:30
     * @Version V1.0
     */
    void deleteByTaskPkId(String taskPkId);

    /**
     * @Method modifyCreateSql
     * @Param
     * @param createSql
     * @param pkId
     * @Return void
     * @Description 更新建表SQL
     * @Author Wang zhihao
     * @Date 2023/8/18 11:16
     * @Version V1.0
     */
    void modifyCreateSql(Clob createSql, String pkId);
}
